package com.kilon.workfaq.service.write.impl;

import com.kilon.workfaq.entity.CategoryPo;
import com.kilon.workfaq.mapper.write.CategoryWriteMapper;
import com.kilon.workfaq.service.write.CategoryWriteService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 博客分类表(Category)表服务实现类
 *
 * @author makejava
 * @since 2023-02-22 23:24:02
 */
@Service("categoryWriteService")
public class CategoryWriteServiceImpl implements CategoryWriteService {
    @Resource
    private CategoryWriteMapper categoryWriteMapper;

    /**
     * 新增数据
     *
     * @param category 实例对象
     * @return 实例对象
     */
    @Override
    public CategoryPo insert(CategoryPo category) {
        this.categoryWriteMapper.insert(category);
        return category;
    }

    /**
     * 修改数据
     *
     * @param category 实例对象
     * @return 实例对象
     */
    @Override
    public boolean update(CategoryPo category) {
        return this.categoryWriteMapper.update(category) == 1;
    }

    /**
     * 通过主键删除数据
     *
     * @return 是否成功
     */
    @Override
    public boolean deleteById(CategoryPo category) {
        return this.categoryWriteMapper.deleteById(category.getId()) == 1;
    }
}
